package revontuli.aMHD.UIhelpers;

import java.util.ArrayList;
import revontuli.aMHD.dataclasses.DeparturesGrouped;
import revontuli.aMHD.R;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class LineScheduleDepartAdapter extends BaseAdapter implements OnClickListener {
	private ArrayList<DeparturesGrouped> mList = new ArrayList<DeparturesGrouped>();
	private Context mContext;

	public LineScheduleDepartAdapter(Context context, ArrayList<DeparturesGrouped> list) {
		this.mContext = context;
		this.mList = list;
//		Log.e("aMHD", Integer.toString(mList.size()));
	}

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int pos) {
		return mList.get(pos);
	}

	@Override
	public long getItemId(int pos) {
		return pos;
	}

	@Override
	public View getView(int pos, View mView, ViewGroup mViewGroup) {
		DeparturesGrouped mDep = mList.get(pos);
		
		if (mView == null) {
			LayoutInflater mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			mView = mInflater.inflate(R.layout.linescheduledepartitem, null);
		}
		
		//RelativeLayout riadok = (RelativeLayout) mView.findViewById(R.id.LineScheduleDepartItem);
		//onclicklistener
		
		TextView mHour = (TextView) mView.findViewById(R.id.lineScheduleDepartureHour);
		mHour.setText(Integer.toString(mDep.hour));
		
		String minuty = mDep.minute.toString();
		minuty = minuty.replaceAll("\\[", "");
		minuty = minuty.replaceAll("\\]", "");
		minuty = minuty.replaceAll(",", "");
		TextView mMinutes = (TextView) mView.findViewById(R.id.lineScheduleDepartureMinutes);
		mMinutes.setText(minuty);
		
		
		return mView;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}

}
